package com.neusoft.yuejian12.yuejian_12.fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


import com.neusoft.yuejian12.yuejian_12.R;
import com.neusoft.yuejian12.yuejian_12.adapter.MatchListAdapter;
import com.neusoft.yuejian12.yuejian_12.javabean.MatchBean;
import com.neusoft.yuejian12.yuejian_12.listener.RetrofitListener;
import com.neusoft.yuejian12.yuejian_12.model.MatchModel;

import java.util.List;


/**
 * A simple {@link Fragment} subclass.
 */
public class MatchFragment extends Fragment implements View.OnClickListener,RetrofitListener<List<MatchBean>> {

    private RecyclerView recyclerView;
    private View view = null;
    private MatchListAdapter matchListAdapter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view =  inflater.inflate(R.layout.fragment_match, container, false);
        initViews();
        getData();
        return view;
    }
    private void initViews(){
        recyclerView = (RecyclerView) view.findViewById(R.id.rV_match);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));
        recyclerView.setItemAnimator(new DefaultItemAnimator());
    }

        private void getData(){
            MatchModel matchModel = new MatchModel();
            matchModel.getMatchList(this);
        }


    @Override
    public void onClick(View v) {

    }

    @Override
    public void onSuccess(List<MatchBean> matchBeen) {
        matchListAdapter = new MatchListAdapter(MatchFragment.this.getActivity(),matchBeen);
        recyclerView.setAdapter(matchListAdapter);
    }

    @Override
    public void onFail() {

    }
}
